﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Practices.ObjectBuilder;
using DemoSupport;

namespace ToolBarDemo
{
	public partial class ToolBarDemoView : DemoViewBase, IToolBarDemoView
	{
		private ToolBarDemoPresenter _presenter;

		[Dependency]
		public ToolBarDemoPresenter Presenter
		{
			get
			{
				return _presenter;
			}
			set
			{
				_presenter = value;
				_presenter.View = this;
			}
		}

		public ToolBarDemoView()
		{
			InitializeComponent();
		}

		#region Example 1

		public static readonly RoutedCommand Example1AddToolBarItem = new RoutedCommand("Example1AddToolBarItem", typeof(ToolBarDemoView));

		public static readonly RoutedCommand Example1CleanUp = new RoutedCommand("Example1CleanUp", typeof(ToolBarDemoView));

		private void Example1AddToolBarItem_CanExecute(object sender, CanExecuteRoutedEventArgs e)
		{
			e.CanExecute = Presenter.Example1CanAddToolBarItem();
		}

		private void Example1AddToolBarItem_Executed(object sender, ExecutedRoutedEventArgs e)
		{
			Presenter.Example1AddToolBarItem();
		}

		private void Example1CleanUp_CanExecute(object sender, CanExecuteRoutedEventArgs e)
		{
			e.CanExecute = Presenter.Example1CanCleanUp();
		}

		private void Example1CleanUp_Executed(object sender, ExecutedRoutedEventArgs e)
		{
			Presenter.Example1CleanUp();
		}

		#endregion

		#region Example 2

		public static readonly RoutedCommand Example2AddToolBarItem = new RoutedCommand("Example2AddToolBarItem", typeof(ToolBarDemoView));

		public static readonly RoutedCommand Example2CleanUp = new RoutedCommand("Example2CleanUp", typeof(ToolBarDemoView));

		private void Example2AddToolBarItem_CanExecute(object sender, CanExecuteRoutedEventArgs e)
		{
			e.CanExecute = Presenter.Example2CanAddToolBarItem();
		}

		private void Example2AddToolBarItem_Executed(object sender, ExecutedRoutedEventArgs e)
		{
			Presenter.Example2AddToolBarItem();
		}

		private void Example2CleanUp_CanExecute(object sender, CanExecuteRoutedEventArgs e)
		{
			e.CanExecute = Presenter.Example2CanCleanUp();
		}

		private void Example2CleanUp_Executed(object sender, ExecutedRoutedEventArgs e)
		{
			Presenter.Example2CleanUp();
		}

		#endregion

		#region Example 3

		public static readonly RoutedCommand Example3AddToolBarItems = new RoutedCommand("Example3AddToolBarItems", typeof(ToolBarDemoView));

		public static readonly RoutedCommand Example3CleanUp = new RoutedCommand("Example3CleanUp", typeof(ToolBarDemoView));

		private void Example3AddToolBarItems_CanExecute(object sender, CanExecuteRoutedEventArgs e)
		{
			e.CanExecute = Presenter.Example3CanAddToolBarItems();
		}

		private void Example3AddToolBarItems_Executed(object sender, ExecutedRoutedEventArgs e)
		{
			Presenter.Example3AddToolBarItems();
		}

		private void Example3CleanUp_CanExecute(object sender, CanExecuteRoutedEventArgs e)
		{
			e.CanExecute = Presenter.Example3CanCleanUp();
		}

		private void Example3CleanUp_Executed(object sender, ExecutedRoutedEventArgs e)
		{
			Presenter.Example3CleanUp();
		}

		#endregion

		public void ShowToolBarItemClicked()
		{
			MessageBox.Show("This message was displayed via the command handler for the tool bar item.");
		}
	}
}
